﻿@model Mvc3UI.ViewModels.ResourceViewModel

@{
    ViewBag.Title = "Edit resource";
}

<h2>@ViewBag.Title</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Resource</legend>

        @Html.HiddenFor(model => model.ModelObject.Id)
        @Html.HiddenFor(model => model.ModelObject.TimeStamp)

        <div class="editor-label">
            @Html.LabelFor(model => model.ModelObject.FirstName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ModelObject.FirstName)
            @Html.ValidationMessageFor(model => model.ModelObject.FirstName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.ModelObject.LastName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.ModelObject.LastName)
            @Html.ValidationMessageFor(model => model.ModelObject.LastName)
        </div>

        <p>
            <input type="submit" value="Save" />
        </p>

    <fieldset>
      <legend>Assignments</legend>
      <table>
        <thead>
          <tr>
            <td>
              Project
            </td>
            <td>
              Assigned
            </td>
            <td>
              Role
            </td>
          </tr>
        </thead>
        <tbody>
          @foreach (var item in Model.ModelObject.Assignments)
          { 
            <tr>
              <td>@item.ProjectName
              </td>
              <td>@String.Format("{0:d}", item.Assigned)
              </td>
              <td>@item.RoleName
              </td>
            </tr>
          }
        </tbody>
      </table>
      @Html.ActionLink("Edit assignments", "Index", "ResourceAssignment", new { id = Model.ModelObject.Id }, null)
    </fieldset>
  </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

